program ifaninh(input,output);
 var m,n,s:integer;

begin
  read(m,n);
  s:=0;
  if m<=n
  then  if n<=s
        then s:=m+1-3
        else s:=2*m
  else  if n>s
        then n:=m+1-3
        else n:=2*m
end.
